package com.hsy.linemoney.common;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

import com.deparse.dpframe.ui.android.widget.MaterialProgressBar.CircleProgressBar;
import com.hsy.linemoney.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by MartinKent on 2016/8/21.
 */
public class GlobalLoadingPopup extends Activity {
    private static List<GlobalLoadingPopup> popups = new ArrayList<>();
    public static final int MSG_DISMISS = 0x7003;

    public static void hide() {
        for (GlobalLoadingPopup popup : popups) {
            popup.finish();
        }
        popups.clear();
    }

    public static class Message {
        public int what;
    }

    protected CircleProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.my_progress_dialog);
        setFinishOnTouchOutside(false);
        popups.add(this);
        initView();
    }

    public static boolean isShowing() {
        return null != popups && popups.size() > 0;
    }

    private void initView() {
        progressBar = (CircleProgressBar) findViewById(R.id.progressWithoutBg);
        progressBar = (CircleProgressBar) findViewById(R.id.progressWithoutBg);
        progressBar.setColorSchemeResources(android.R.color.holo_red_light);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        return true;
    }
}
